<html>
<head>
    <title>愿望清单</title>
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js">
    </script>
    <script>
    $(document).ready(function(){
        $('input:checkbox').click(function() {
            var tid = $(this).attr("tid");
            $.post("/todo/finish",
                {
                    tid: tid, 
                },
                function(data, status) {
                    if (status == "success") {
                        location.href="/todo/list";
                    } else {
                        alert(status)
                        return;
                    }
                }
            )
            .error(function() { 
                alert("未完成，请刷新后重试。"); 
            });
        });
    });
    </script>
</head>
<body>
    <div align="center">
        <h2>
            {{.username}} 的愿望清单
        </h2>
        <a href="/">大家的愿望</a><br>
        <a href="/todo/new">新的愿望</a>
        {{if .is_staff}}
        <br><a href="/approve/list">待审核列表</a>
        {{end}}
        <hr>
        {{range .todos}}
        <p><big><input type="checkbox" tid="{{.ID}}" {{if .Finished}}checked disabled{{end}}> {{.Desc}} {{if not .Public}}🔒{{end}}</big></p>
        <p><small>创建时间：{{.Begin.Format "2006/01/02 15:04"}}</small></p>
        {{if .Finished}}<p><small>完成时间：{{.End.Format "2006/01/02 15:04"}}</small></p>{{end}}
        <hr>
        {{end}}

    </div>
</body>
</html>